package com.munhrasoft.elearning.business.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
@NamedQueries(value = {
    @NamedQuery(name = "findAllExercises", query = "SELECT e FROM Exercises e"),
    @NamedQuery(name = "findExercisesByTitle", query = "SELECT e FROM Exercises e WHERE lower(e.title) "
            + "LIKE :title") })
@SequenceGenerator(name = "exercisesSeq", initialValue = 1, allocationSize = 1)
public class Exercises {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "exercisesSeq")
    private Long            id;
    private String          title;
    private String          exerciseText;
    private String          answerText;
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Questions> questions;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<Questions> getQuestions() {
        return questions;
    }

    public void setQuestions(List<Questions> questions) {
        this.questions = questions;
    }

    public String getExerciseText() {
        return exerciseText;
    }

    public void setExerciseText(String exerciseText) {
        this.exerciseText = exerciseText;
    }

    public String getAnswerText() {
        return answerText;
    }

    public void setAnswerText(String answerText) {
        this.answerText = answerText;
    }

}
